﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace FlickrSL.Data
{
    public enum PhotoField
    {
        Description = 0,
        License,
        DateUploaded,
        DateTaken,
        DateLastUpdated,
        OwnerName,
        IconServer,
        OriginalFormat,
        GeoLocation,
        Tags,
        MachineTags,
        OriginalDimensions,
        Views,
        Media,
        PathAlias,
        SquareUrl,
        TinyUrl,
        SmallUrl,
        MediumUrl,
        OriginalUrl
    }

    public class PhotoFieldCollection : List<PhotoField>
    {
        private static readonly String[] FieldNames = new String[] { 
        "description",
        "license",
        "date_upload",
        "date_taken",
        "last_update",
        "owner_name",
        "icon_server",
        "original_format",
        "geo",
        "tags",
        "machine_tags",
        "o_dims",
        "views",
        "media",
        "path_alias",
        "url_sq",
        "url_t",
        "url_s",
        "url_m",
        "url_o"
        };

        public PhotoFieldCollection()
            : base()
        {
        }

        public PhotoFieldCollection(Int32 capacity)
            : base(capacity)
        {
        }

        public PhotoFieldCollection(IEnumerable<PhotoField> fields)
            : base(fields)
        {
        }

        public PhotoFieldCollection(params PhotoField[] fields)
            : base(fields)
        {
        }

        public override string ToString()
        {
            return String.Join(",", this.Select(field => FieldNames[(Int32)field]));
        }

        public static readonly PhotoFieldCollection s_All = new PhotoFieldCollection(
            PhotoField.Description,
            PhotoField.License,
            PhotoField.DateUploaded,
            PhotoField.DateTaken,
            PhotoField.DateLastUpdated,
            PhotoField.OwnerName,
            PhotoField.IconServer,
            PhotoField.OriginalFormat,
            PhotoField.GeoLocation,
            PhotoField.Tags,
            PhotoField.MachineTags,
            PhotoField.OriginalDimensions,
            PhotoField.Views,
            PhotoField.Media,
            PhotoField.PathAlias,
            PhotoField.SquareUrl,
            PhotoField.TinyUrl,
            PhotoField.SmallUrl,
            PhotoField.MediumUrl,
            PhotoField.OriginalUrl);

        public static PhotoFieldCollection All
        {
            get { return PhotoFieldCollection.s_All; }
        }
    }
}
